//
//  NSObject+Invocation.m
//  ResponderChainDemo
//
//  Created by 陈嘉鸿 on 2019/9/16.
//  Copyright © 2019 1jbest. All rights reserved.
//

#import "NSObject+Invocation.h"

@implementation NSObject (Invocation)

- (NSInvocation *)createInvocationWithSelector:(SEL)aSelector {
    NSMethodSignature *signature = [[self class] instanceMethodSignatureForSelector:aSelector];
    
    if (!signature)
    {
//        NSString *info = [NSString stringWithFormat:@"-[%@ %@]:unrecognized selector sent to instance", [self class], NSStringFromSelector(aSelector)];
//        @throw [[NSException alloc] initWithName:@"remind:" reason:info userInfo:nil];
        return nil;
    }
    
    NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];
    invocation.target = self;
    invocation.selector = aSelector;
    
    return invocation;
}

@end
